﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NhJump.Persistence.Context;
using NHibernate;
using NhJump.Persistence.Querying;
using NhJump.Persistence.Model;

namespace NhJump.Persistence
{
    /// <summary>
    /// Repository of aggregate roots.
    /// </summary>
    public interface IRepository<TEntity, TIdentifier> : IReadableRepository<TEntity, TIdentifier>
        where TEntity : IRootAggregateDomainEntity<TIdentifier>
    {
        /// <summary>
        /// Fetch an Id and schedule an INSERT for a new entity, or schedule an UPDATE of an existing entity
        /// </summary>
        /// <param name="entity"></param>
        void SaveOrUpdate(TEntity entity);

        /// <summary>
        /// Associate a persistent entity with the current session, without scheduling an UPDATE. Changes already made to the entity will be lost.
        /// </summary>
        /// <param name="persistent"></param>
        void AttachUnchanged(TEntity persistent);

        /// <summary>
        /// Mark entity as being deleted.  
        /// </summary>
        /// <param name="forDeletion"></param>
        void Delete(TEntity forDeletion);
    }
}
